<template>
  <div style="padding: 10px 15px">
    <div class="filter_fenge" />
    <div class="filter-container">
      <el-button
        class="filter-item seachbttn"
        type="primary"
        icon="el-icon-search"
        @click="handleFilter"
        >查询</el-button
      >
    </div>
    <!--table-->
    <el-table
      v-loading="listLoading"
      :data="PymcverrcdData"
      fit
      highlight-current-row
      style="width: 100%"
      stripe
    >
      <el-table-column label="标题" align="right" min-width="450px">
        <template slot-scope="{ row }">
          <span>{{ row.title }}</span>
        </template>
      </el-table-column>
      <el-table-column label="企业名称" v-if="this.sys=='system'" align="right" min-width="180px">
        <template slot-scope="{ row }">
          <span>{{ row.cpnIDStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="类型" align="right" min-width="60px">
        <template slot-scope="{ row }">
          <span>{{ row.notTypeStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="类别" align="right" min-width="60px">
        <template slot-scope="{ row }">
          <span>{{ row.notCtgryStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="阅读状态" align="right" min-width="60px">
        <template slot-scope="{ row }">
          <span v-if="row.isRead == 0" class="red">未阅读</span>
          <span v-if="row.isRead == 1" class="green">已阅读</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="left" min-width="100px">
        <template slot-scope="{ row }">
          <span>{{ row.crtStr }}</span>
        </template>
      </el-table-column>

      <!--
          <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
     -->
    </el-table>

    <pagination
      v-show="listQuery.total > 0"
      :total="listQuery.total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="fetchData(this)"
    />

    <!--table-->

    <!--详情-->
    <el-dialog title="详情" :visible.sync="dialogdetailsVisible" width="55%">
      <el-form :model="details_form" :inline="true" label-position="right" />
    </el-dialog>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import { AjaxToken } from "@/api/common";
import { SelectAjax } from "@/api/common";
import sessionStorage from "@/api/Storage";
import "url-search-params-polyfill";
export default {
  name: "PyMcVerRcd",
  components: { Pagination },
  data() {
    return {
      sys:"",
      formLabelWidth: "120px",
      PymcverrcdData: null,
      listQuery: {
        title: "",
        total: 0,
        page: 1,
        limit: 10,
      },
      listLoading: true,
      dialogFormVisible: false,
      dialogdetailsVisible: false,
      dialogStatus: "",
      textMap: {
        update: "修改",
        create: "添加",
      },
      form: {
        iD: "",
        verurl: "",
        comment: "",
        version: "",
        dt: "",
        uptr: "",
      },
      details_form: {
        iD: "",
        verurl: "",
        comment: "",
        version: "",
        dt: "",
        uptr: "",
      },
    };
  },
  created() {
    debugger;
    var user = JSON.parse(sessionStorage.getItem("userinfo"));
    this.user = user;
    this.sys = user.cpnId;
    this.fetchData();
  },
  methods: {
    handleFilter(row) {
      this.fetchData();
    },
    handleCreate() {
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
    },
    handleClick(row) {
      var params = new URLSearchParams();
      params.append("id", row.id);
      this.dialogdetailsVisible = true;
    },
    saveForm() {},
    fetchData() {
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQuery.page +
          ',"rows":' +
          this.listQuery.limit +
          "}"
      );
      params.append("CpnID",this.sys);
      backstage.GetCpnNotcRcdList(this, params);
    },
  },
};
// 后台事件
var backstage = {
  // 获取Pymcverrcd集合
  GetCpnNotcRcdList: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "GetCpnNotcRcdList",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        var body = res.data.data;
        thisobj.PymcverrcdData = body.rows;
        thisobj.listQuery.page = body.page;
        thisobj.listQuery.total = body.records;
      },
      function (err) {}
    );
  },
};
</script>

<style scoped>
.red {
  color: red;
}

.green {
  color: green;
}
</style>